home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS6.ZIP / DOSMISC < prev    next >
Text File  |  1987-02-22  |  20KB  |  476 lines

  1.                        Diagnostic Shortcut
  2.        (PC Magazine Vol 6 No 1 Jan 13, 1987 User-to-User)
  3.  
  4.      A user had to use the IBM Diagnostics disk on his PC, but since
  5. the problem was elusive he had to run multiple tests with errors
  6. logged to the printer.  This led to two problems that were both solved
  7. by a single trick.  The first problem arose because the disk drives
  8. are tested in every loop.  He was certain that there was no problem
  9. in the disk drives, and the disk drive tests are time-consuming and
  10. put a lot of wear and tear on the drives.  The second problem arose
  11. because the diagnostics do not provide a count of the number of loops
  12. that have been run.
  13.      The trick is to put write-protected disks in the disk drives.  The
  14. diagnostics will quickly detect that a disk is write-protected, abort
  15. the test on that drive, send an error message to the printer, and move
  16. on to the next test.  On a two-disk-drive system, each loop generates
  17. two write-protect errors and one disk drive error.  You can determine
  18. the number of loops by counting the number of error sets.
  19.      The same effect can be achieved by putting no disks in the drives,
  20. but the diagnostics take much longer to decide that there is no disk
  21. in a drive than to decide that there is a write-protected disk in the
  22. drive.
  23.      Editor's Note:  This technique makes it less traumatic to figure
  24. out what's wrong with your system.  It was good of IBM to distribute
  25. diagnostic disks, but it should have included a decent section in the
  26. Guide to Operations explaining what all the tests do and what any
  27. reported error codes mean.  And it should also have given you a real
  28. menu that lets you jump to the appropriate test rather than forcing
  29. you to wade through the whole routine.  But while the GTO is pathetic
  30. about defining errors, IBM's Hardware Maintenance and Service manuals
  31. are terrific.  They tell you what tools you need, explain everything
  32. in absorbing detail, and flowchart you painlessly through the testing
  33. procedures.  It's all clear and concise, and the manual is crammed
  34. with helpful illustrations.  And you get a copy of the Advanced
  35. Diagnostics with it.
  36.  
  37. -----------------------------------------------------------------
  38.                          Memory Checker
  39.        (PC Magazine Vol 6 No 1 Jan 13, 1987 User-to-User)
  40.  
  41.      With all the memory-resident programs and different ways that you
  42. can configure these programs -- as well as your own system -- with
  43. buffers, it would be nice to know how much available memory is left
  44. for your applications programs.
  45.      MEMORY.COM is a simple program that returns the current free RAM.
  46. To create MEMORY.COM, run the following MEMORY.SCR file with DEBUG:
  47.  
  48. DEBUG < MEMORY.SCR
  49.  
  50. Be sure the blank line after DB  0 near the end of the program is
  51. there; it's necessary.  You must have DOS 2.0 or later for MEMORY.COM.
  52. MEMORY.COM reports bytes free in Ks (1024s) while CHKDSK reports them
  53. in 1000s.
  54.  
  55. A
  56. XOR    BX,BX
  57. MOV    AH,4A
  58. INT    21
  59. MOV    AH,48
  60. MOV    BX,FFFF
  61. INT    21
  62. MOV    AX,BX
  63. XOR    DX,DX
  64. MOV    CX,40
  65. DIV    CX
  66. CMP    DX,20
  67. JB    11C
  68. INC    AX
  69. MOV    BX,AX
  70. MOV    CX,64
  71. CALL    139
  72. MOV    CX,A
  73. CALL    139
  74. MOV    CX,1
  75. CALL    139
  76. MOV    DX,15C
  77. MOV    AH,9
  78. INT    21
  79. INT    20
  80. MOV    AX,BX
  81. XOR    DX,DX
  82. DIV    CX
  83. MOV    BX,DX
  84. MOV    DL,AL
  85. CMP    AL,0
  86. JZ    14B
  87. OR    [15B],AL
  88. CMP    BYTE PTR [15B],0
  89. JA    153
  90. RET
  91. ADD    DL,30
  92. MOV    AH,2
  93. INT    21
  94. RET
  95. DB    0
  96.  
  97. E 15C "K Bytes free$"
  98. RCX
  99. 69
  100. N MEMORY.COM
  101. W
  102. Q
  103.  
  104. -----------------------------------------------------------------
  105.                          What is a PIF?
  106.          (PC Magazine Vol 6 No 1 Jan 13, 1987 PC Tutor)
  107.  
  108.      PIF stands for "Program Information File."  IBM invented the .PIF
  109. file for use with its TopView operating environment.  Although TopView
  110. has pretty much bitten the dust, Microsoft has also used .PIF files for
  111. its Windows operating environment.
  112.      There are several different kinds of programs you can run under
  113. Microsoft Windows.  The first category is a "Windows application."
  114. This is a program specifically written for Windows, and it does not
  115. run under plain DOS.  This category includes the utilities that come
  116. with Windows (Write, Paint, Clock, etc.) and a few programs from other
  117. manufacturers.  Many normal programs that run under DOS can still run
  118. under Windows, however.  These programs are called either "standard
  119. applications" or "old applications."
  120.      When you want to run an old application under Windows, Windows
  121. looks for a .PIF file with the name of that application.  The .PIF file
  122. contains information about the program.  Among other things, it tells
  123. Windows how much memory the application needs and just how "well
  124. behaved" the program is.
  125.      The "well behaved" criterion covers several items, but in most
  126. cases it comes down to the following question: Does the application
  127. write directly to the display memory?  In the case of virtually all
  128. word processors, spreadsheets, and graphics programs, the answer is
  129. yes.  Windows cannot run these programs in a window, and it cannot
  130. multitask them.  Windows must give up the entire display because it
  131. has no way of knowing when the program will write to the screen.
  132.      A program that does not write directly to display memory (but
  133. instead goes through DOS or the BIOS to display something on the
  134. screen) can be run in a window, share the screen with other
  135. applications, and be multitasked.
  136.      These two categories of programs not designed to run under Windows
  137. are sometimes called "bad applications" (cannot be run in a window) and
  138. "good old applications" (can run in a window).  The terms "good" and
  139. "bad" here denote only how the program uses the hardware of the PC and
  140. not how well the program works.  Some of the best programs around are
  141. "bad applications" as far as Windows is concerned.  Some of them are
  142. so bad they cannot be run under Windows at all.  The "baddest" program
  143. of them all, for instance, is probably SideKick.
  144.      Windows also allows "good old applications" to be listed in the
  145. WIN.INI file so they don't need .PIF files.  If you try to run an old
  146. application under Windows without a .PIF file, Windows will ask if you
  147. want to use the default .PIF settings, which assume that it's a "bad
  148. application."
  149.      Windows includes a program called PIFEDIT to create or modify .PIF
  150. files.  The actual internal format of the .PIF file is documented in
  151. IBM's TopView Programmer's Toolkit.
  152.      The .PIF file is a convenient way for an advanced operating system
  153. to deal with programs written for the anarchic "anything goes" DOS
  154. environment.  A .PIF file (or something like it) may appear to play an
  155. important role in a future version of DOS that supports the PC AT's
  156. 80286 microprocessor in protected mode.
  157.  
  158. -----------------------------------------------------------------
  159.                       Another ANSI Solution
  160.          (PC Magazine Vol 6 No 3 Feb 10, 1987 PC Tutor)
  161.  
  162.      You can use ANSI.SYS to redefine the keyboard.  For example, to
  163. execute the command line "DIR/P" by hitting an Alt-D on the keyboard,
  164. you can include the following line in your AUTOEXEC.BAT file (ANSI.SYS
  165. must be loaded by including the line DEVICE=ANSI.SYS in your CONFIG.SYS
  166. file):
  167.  
  168. ECHO <Esc>[0;32;"DIR /P";13p
  169.  
  170. The <Esc> doesn't mean the characters <, E, s, c, and >.  It means the
  171. ASCII escape character must be there.  The escape character is a
  172. difficult character to enter in many text editors.  It's fairly easy
  173. in EDLIN, however: you type a Ctrl-V followed by a left bracket.  So,
  174. when typin in the line in EDLIN, you would actually type:  ECHO, a
  175. space, a Ctrl-V, a left bracket, another left bracket, a 0, and so on.
  176.      The 0;32 means that you're defining an extended keyboard key that
  177. has a code of 32.  That's the Alt-D combination.  The 13 means a
  178. carriage return, and the p at the end identifies the control sequence
  179. as a keyboard redefinition.
  180.     In this example, you can't use $e to represent the escape character
  181. because that's something only the PROMPT command understands.  However,
  182. you can use the PROMPT command instead of ECHO for redefining the keys,
  183. as shown in the next item.
  184.  
  185. -----------------------------------------------------------------
  186.                        And an ANSI Problem
  187.          (PC Magazine Vol 6 No 3 Feb 10, 1987 PC Tutor)
  188.  
  189.      Using ANSI.SYS and the PROMPT command, the following lines were
  190. included in an AUTOEXEC.BAT file in an effort to redefine the function
  191. keys:
  192.  
  193. PROMPT $e[0;64;"DIR";13p
  194. PROMPT $e[0;66;"DIR /W";13p
  195. PROMPT $e[0;67;"DIR /P";13p
  196. PROMPT $e[0;68;"CLS";13p
  197. PROMPT $e[33;44m$n$g$e[36;44m
  198.  
  199. The first four PROMPT commands redefine the function keys F8 through
  200. F10.  The last PROMPT command sets the prompt to brown-on-blue and the
  201. text to cyan-on-blue.
  202.      When rebooting, every command flashes on the screen.  ECHO OFF
  203. cannot be added preceding the PROMPT commands, because it prevents the
  204. PROMPT commands from executing.
  205.      The reason is ANSI.SYS is a video display driver.  It will
  206. interpret a control sequence only if some program makes an attempt to
  207. display the control sequence on the screen.  ANSI.SYS doesn't put the
  208. control sequence on the screen because it recognizes it as a command
  209. to do something (in this case, to redefine a key) rather than
  210. displayable text.
  211.      When COMMAND.COM executes the batch file, then, the line with the
  212. first PROMPT command is displayed on the screen.  You'll see the whole
  213. PROMPT command just as you've type it because that's not the control
  214. sequence.  An ANSI control sequence begins with an escape code and the
  215. PROMPT argument begins with a $e.  COMMAND.COM then executes this
  216. PROMPT command, which sets a new prompt.
  217.      Next, COMMAND.COM displays the new prompt, followed by the next
  218. line in the batch file.  As it displays the new prompt, COMMAND.COM
  219. replaces the $e with an escape code.  That makes the new prompt an
  220. ANSI control sequence.  You won't see the new prompt on the screen
  221. because ANSI.SYS interprets it as a command to redefine a key.
  222.      When you use ECHO OFF, COMMAND.COM doesn't display the prompt for
  223. each line it executes.  If it doesn't display these prompt, ANSI.SYS
  224. never sees them.  Thus, the keys don't get redefined.
  225.      If you want to use ECHO OFF, use an ECHO command instead of
  226. PROMPT for the first four lines and replace the $e with an escape
  227. code.  Alternatively, you can place all the ANSI.SYS key redefinition
  228. control sequences in a separate file (call it KEY.DAT) that looks like:
  229.  
  230. <Esc>[0;65;"DIR";13p
  231. <Esc>[0;66;"DIR /W";13p
  232.  
  233. and so forth.  You can even put them all on one line if you want.
  234. Then, in your AUTOEXEC.BAT, you can display this file to the screen
  235. (and have ANSI.SYS redefine the keys) by the command:
  236.  
  237. TYPE KEY.DAT
  238.  
  239. If you've done it right, you won't see the KEY.DAT file.
  240.  
  241. -----------------------------------------------------------------
  242.                        Powerful F3 Tricks
  243.        (PC Magazine Vol 6 No 4 Feb 24, 1987 User-to-User)
  244.  
  245.      Most users alrady know about the muscle of the F3 key, which
  246. repeats the previous DOS command.  You can use the F3 key in conjuction
  247. with the Ins and Del keys to adapt the previous command.
  248.      Even better, if you want to repeat a DOS command but want to do
  249. an intermediate DOS command before you repeat it, you can "park" the
  250. command you want to repeat by hitting the Ins key, typing in the
  251. intermediate command and adding an extra space at the end of it,
  252. hitting the F3 to put the previous command at the end of the line,
  253. and then hitting Enter.
  254.      DOS will stop reading when it sees the extra space and will
  255. execute the intermediate command.  Then you simply tap the Del key
  256. the correct number of times to erase the intermediate command, hit F3,
  257. and you have the original command back that you "parked."  However,
  258. this works only with certain DOS command that don't read switches off
  259. the command line.
  260.      Two other sterling uses of the F3 key are in verifying copies and
  261. deleting after copies are made.
  262.      If you want to copy all the .COM files from C:\DOS\BIN\UTILS to
  263. B:, you could type:
  264.  
  265. COPY C:\DOS\BIN\UTILS\*.COM B:
  266.  
  267. To check whether the copies wer valid, you could type:
  268.  
  269. COMP
  270.  
  271. and hit the F3 key.  Since the COPY and COMP instructions are the same
  272. length and share the same command structure, this makes verifying the
  273. copies a painless process.  (You could have added a /V switch to the
  274. end of the COPY command, but this doesn't do a real line-by-line or
  275. byte-by-byte comparison the way COMP of FC or a real compare program
  276. does.)
  277.      Another handy F3 technique is moving files from one subdirectory
  278. to another.  If you wanted to move:
  279.  
  280. C:\DOS\BIN\UTILS\COLOR.COM
  281.  
  282. to the current subdirectory, you could type:
  283.  
  284. COPY C:\DOS\BIN\UTILS\COLOR.COM
  285.  
  286. (and then COMP it if you wanted, by hitting COMP and then F3).  Then
  287. you can delete the original by typing:
  288.  
  289. DEL
  290.  
  291. and then tapping once on the space bar (since DEL is one character
  292. shorter than COPY) and then hitting F3 and Enter.
  293.      Of course, when moving, copying, and deleting files, it may be
  294. better to run the operation out of batch files.
  295.      Speaking of batch files, here are two related ones that let you
  296. delete files selectively.  They'll display the files you want deleted
  297. and offer you the chance to delete them or leave them alone.  The only
  298. strictly non-DOS part is a tiny GETYES.COM utility that handles an
  299. IF ERRORLEVEL branching operation.  First, create a batch file called
  300. DELETE.BAT:
  301.  
  302. ECHO OFF
  303. IF %1!==! GOTO OOPS
  304. FOR %%i IN (%1) DO COMMAND /C D %%i
  305. GOTO END
  306. :OOPS
  307. ECHO Enter a filespec (like *.COM)
  308. :END
  309.  
  310. Then create a companion batch file called D.BAT:
  311.  
  312. ECHO OFF
  313. ECHO Delete %1 (Y/N)?
  314. GETYES
  315. IF ERRORLEVEL 255 GOTO DOIT
  316. ECHO %1 NOT deleted ...
  317. GOTO END
  318. :DOIT
  319. DEL %1
  320. ECHO %1 deleted...
  321. :END
  322.  
  323.      To make this work, you need GETYES.COM.  Use the GETYES.SCR below.
  324. Make sure you leave a blank line after INT 21 and hit the Enter key
  325. after each line, especially the last one.  Then put GETYES.SCR and
  326. DEBUG on a disk and at the DOS prompt type:  DEBUG < GETYES.SCR
  327.  
  328. A
  329. MOV AH,00
  330. INT 16
  331. CMP AL,59
  332. JZ  010C
  333. CMP AL,79
  334. JNZ 010E
  335. MOV AL,FF
  336. MOV AH,4C
  337. INT 21
  338.  
  339. N GETYES.COM
  340. RCX
  341. 12
  342. W
  343. Q
  344.  
  345. (To use N and n rather than Y and y to trigger ERRORLEVEL, substitute
  346. 4E and 6E for 59 and 79, and change GETYES.COM to GETNO.COM.)
  347.      This may seem like a lot of files and a lot of typing, but it can
  348. save you lots of anguish.  To use it, just type DELETE followed by a
  349. filespec (such as C*.* or *.COM).  The batch files will display the
  350. names of all matching files one by one and ask whether or not you wnat
  351. to delete them.  If you answer Y (or y) the file will be erased; an N
  352. (or n) will skip over a file without erasing.
  353.  
  354. -----------------------------------------------------------------
  355.                             No Bytes
  356.        (PC Magazine Vol 6 No 5 Mar 10, 1987 User-to-User)
  357.  
  358.      Say you need a 0-byte file called XS.SYS.  You can redirect the
  359. output of a batch file to the file called XS.SYS.  Create TEST.BAT as
  360. follows:
  361.  
  362. COPY CON:TEST.BAT
  363. GO
  364.  
  365. Then type:
  366.  
  367. TEST > XS.SYS
  368.  
  369. (You should get a "Bad filename" or "File not found" message; ignore
  370. it.)  Now issue a DIR command and you'll see a listing for XS.SYS that
  371. is 0 bytes long.
  372.      An easier way to create a 0-length file named XS.SYS is to use
  373. DEBUG:
  374.  
  375. DEBUG XS.SYS
  376. W
  377. Q
  378.  
  379. Again, ignore the "File not found" message.
  380.  
  381. -----------------------------------------------------------------
  382.                      DEBUG and Disk Sectors
  383.          (PC Magazine Vol 6 No 5 Mar 10, 1987 PC Tutor)
  384.  
  385.      DEBUG can be used to turn on the "hidden" attribute of a file or
  386. directory on a floppy disk ("Keeping Your Files Private," PC Magazine
  387. Vol 5 No 16 September 30, 1986).  It can also be used to hide a
  388. directory on a hard disk.
  389.  
  390.      However, USING DEBUG TO ALTER DIRECTORY INFORMATION IS NOT
  391. RECOMMENDED!!!!!
  392.  
  393.      It's not so bad with a floppy disk because the worst that can
  394. happen is that you lose 360K of data.  With a hard disk, however, you
  395. could lose the contents of the entire disk!!!!  There is just too much
  396. that could go wrong when you use the DEBUG L and W commands to modify
  397. disk sectors.
  398.      There is also the problem of the sector where the root directory
  399. on a hard disk begins.  The root directory does not always begin a
  400. specific sector.  Its starting point depends upon the size of the hard
  401. disk, the size of the DOS partition, and whether the file allocation
  402. table contains 12-bit or 16-bit cluster entries.
  403.      The DOS function call that reports the starting sector of the
  404. root directory has not been documented by Microsoft.  (Some unofficial
  405. documentation of this function call can be bound in "Diskscan Finds
  406. Bad Sectors" in PC Magazine Vol 5 No 8 April 29, 1986.)  Even with this
  407. information, however, you can find the location of noly the root
  408. directory.  Subdirectories may be anywhere on the hard disk.  You would
  409. have to find the starting cluster number of the subdirectory from the
  410. root directory, convert that to a sector number, and then load that
  411. sector into DEBUG.
  412.      A much better method for changing file attributes is ATTR, a
  413. program in PC Magazine Vol 5 No 11 June 10, 1986.
  414.      Nevertheless, this is how to do something that you don't want to
  415. do.
  416.      To modify the root directory on a hard disk directly, you must
  417. first determine the location of the root directory.  You can do this
  418. with information from the boot sector, which is sector 0.  (This
  419. information may not appear on a disk that is not bootable or that uses
  420. its own driver files.)  Load sector 0 of the hard disk into DEBUG with:
  421.  
  422. L 100 2 0 1
  423.  
  424. The 100 is the memory address where the sector is to be loaded, 2
  425. refers to drive C, 0 means sector 0, and 1 means "read 1 sector."
  426.      Now do a DEBUG D command.  The 2 bytes at offset 10Eh are the
  427. number of "reserved sectors" and will probably be 1.  (Remember to
  428. switch the order of the 2 bytes to convert them into a word.)  The
  429. single byte at offset 100h is the number of the file allocation
  430. tables (FATs).  This will probably be 2.  The 2 bytes at offset 116h
  431. contain the number of sectors per FAT.  On one particular 30-megabyte
  432. hard disk this is 3Dh, or 59 in decimal.  (Different 30-megabyte hard
  433. disks may be different.)  Multiply the number of FATs by the number
  434. of sectors per FAT.  Add the number of reserved sectors.  For the 30-
  435. megabyte hard disk on which this technique was explored, it came to
  436. 7Bh.  That is the sector where the root directory begins.
  437.      The size of the root directory can be calculated just as easily,
  438. though remember that you really don't want to do this.  The number of
  439. root directory entries is the word at offset 111h.  For most hard
  440. disks, this will equal 200h, or 512 decimal.  Multiply this by 20h
  441. (32 decimal), which is the number of bytes per directory entry.  That
  442. comes out to 4000h, which is 32,768 in decimal.  Now divide that number
  443. by the bytes per sector, which is the word at offset 10Bh and should be
  444. 200h (512 bytes).  The result is 20h (32 decimal) sectors for the
  445. length of the root directory.
  446.      (The information on the layout of the boot sector is documented
  447. in the DOS Technical Reference manual in the section on device
  448. drivers.)
  449.      You can load the root directory into DEBUG with the command:
  450.  
  451. L 100 2 7B 20
  452.  
  453. You should use the number you calculated for the starting sector of
  454. your root directory instead of the 7B above, and the number you
  455. calculated for the length of your root directory instead of 20.  After
  456. you do this you can see your entire root directory by executing:
  457.  
  458. D 100 L 4000
  459.  
  460. If you're still all right here, you can follow the directions given in
  461. "Keeping Your Files Private" for modifying the attribute byte of a
  462. file or directory.  When you're done, take a deep breath and type
  463. carefully:
  464.  
  465. W 100 2 7B 20
  466.  
  467. again substituting your own calculated values for the 7B and 20.
  468. Notice that the W and L commands shown here use the same parameters.
  469. That's the easiest and safest way to make sure that what you loaded
  470. from the disk gets written back to the same place.
  471.      Again, using DEBUG to modify any disk directly is dangerous if
  472. you value the data on the disk.  If you try it and mess up your disk,
  473. it's your own fault.  Besides, ATTR.COM does the job much more
  474. easily.
  475.  
  476.